import { url } from '../../build/config'
import ajax from './ajax'


const base_url = url.base_url + '/api/qa-question';

export function questionAdd(data) {
  return ajax({
    url: `${base_url}`,
    method: 'post',
    data: data,
    showMsg: true,
  })
}

export function questionUpdate(data) {
  return ajax({
    url: `${base_url}`,
    method: 'put',
    data: data,
    showMsg: true,
  })
}

export function questionDelete(key) {
  return ajax({
    url: `${base_url}/${key}`,
    method: 'delete',
    showMsg: true,
  })
}

export function questionPage(data) {
  return ajax({
    url: `${base_url}/page`,
    method: 'post',
    data: data,
  })
}

export  function questionGet(key) {
  return ajax({
    url: `${base_url}/${key}`,
    method: 'get',

  })
}

export function currentQuestionPage(data) {
  return ajax({
    url: `${base_url}/current/page`,
    method: 'post',
    data: data,
  })
}

export function questionSolved(key) {
  return ajax({
    url: `${base_url}/solved/${key}`,
    method: 'put',
    showMsg: true,
  })
}

export function esQuestionList(keyword) {
  return ajax({
    url: `${base_url}/es/list`,
    method: 'get',
    data: {keyword: keyword},
  })

}
